# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=kdeconnect
pkgver=22.04.3
pkgrel=0
pkgdesc="Adds communication between KDE and your smartphone"
url="https://community.kde.org/KDEConnect"
# armhf blocked by extra-cmake-modules
# s390x and riscv64 blocked by polkit -> kio
arch="all !armhf !s390x !riscv64"
license="GPL-2.0-only OR GPL-3.0-only"
depends="
	kirigami2
	qt5-qtquickcontrols
	sshfs
	"
makedepends="
	extra-cmake-modules
	kcmutils-dev
	kconfigwidgets-dev
	kdbusaddons-dev
	kdoctools-dev
	ki18n-dev
	kiconthemes-dev
	kio-dev
	kirigami2-dev
	knotifications-dev
	kpeople-dev
	kpeoplevcard-dev
	kservice-dev
	kwayland-dev
	libfakekey-dev
	pulseaudio-qt-dev
	qca-dev
	qqc2-desktop-style-dev
	qt5-qtbase-dev
	qt5-qtmultimedia-dev
	samurai
	"
checkdepends="xvfb-run"
subpackages="$pkgname-doc $pkgname-lang $pkgname-nftables"
source="https://download.kde.org/stable/release-service/$pkgver/src/kdeconnect-kde-$pkgver.tar.xz
	60_kdeconnect.nft
	"
builddir="$srcdir/$pkgname-kde-$pkgver"

# secfixes:
#   20.08.2-r0:
#     - CVE-2020-26164

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_LIBEXECDIR=lib
	cmake --build build
}

check() {
	cd build
	# testsslsocketlinereader, testnotificationlistener and sendfiletest are broken
	CTEST_OUTPUT_ON_FAILURE=TRUE xvfb-run ctest -E "testsslsocketlinereader|testnotificationlistener|sendfiletest"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

nftables() {
	pkgdesc="$pkgdesc (nftables rules)"
	install_if="$pkgname=$pkgver-r$pkgrel nftables"

	install -Dm644 -t "$subpkgdir"/etc/nftables.d "$srcdir"/60_kdeconnect.nft
}

sha512sums="
b09577ee6e5cc9fb73a3691ddaf55a7e7e33dc599db9abeffeb1fa812867c96290af7d445a39da6b2309a84c21d777ecccdf4f0f3c02e3723d9793f8e4775a36  kdeconnect-kde-22.04.3.tar.xz
0ccc2cb0ffd3892698b45bcf723cfdd23ad98f0e2b0436cd0a91d9ed13c6992853e2c4092ee8a0edc6216f1f262151e99e344b8f16c52237e9ff8de62fd37cae  60_kdeconnect.nft
"
